@echo off
setlocal enabledelayedexpansion

:: 设置路径
set SRC_DIR=src
set BIN_DIR=%SRC_DIR%\bin_vs
set DLL_DIR=%SRC_DIR%\dll_lib
set DEPLOY_DIR=tmp_deploy

:: 清理旧的打包目录
if exist %DEPLOY_DIR% rd /s /q %DEPLOY_DIR%
mkdir %DEPLOY_DIR%


echo === 1. 拷贝主程序到部署目录 ===
xcopy /s /e /y /q %BIN_DIR%\PackTest.exe %DEPLOY_DIR%\

echo === 2. 执行 windeployqt 自动补全 Qt 依赖 ===
for %%f in (%DEPLOY_DIR%\*.exe) do (
    echo ---- 处理 Qt 依赖: %%~nxf
    windeployqt.exe --no-angle --no-system-d3d-compiler --no-quick-import %DEPLOY_DIR%\%%~nxf
)

echo === 3. 拷贝额外 资源 ===
xcopy /y /q %DLL_DIR%\*.* %DEPLOY_DIR%\

echo === 4. 拷贝 Qt 配置（如有） ===
if exist qt.conf (
    copy /y qt.conf %DEPLOY_DIR%\ >nul
)

echo === 5. 打包 Inno Setup 安装包 ===
set InnoScript=LIBS_Server_setup.iss

if exist "%InnoScript%" (
    echo ---- 使用 Inno Setup 打包...
    iscc "%InnoScript%"
) else (
    echo !! Inno Setup 脚本文件未找到: %InnoScript%
)


echo === 6. 完成 ===
endlocal
pause